package com.cloudsigns.factorymanager2.project.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.engineering.adapter.AddConstructContentAdapter;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringConstructContentBean;
import com.cloudsigns.factorymanager2.project.myinerface.ItemCheckedChangeListener;
import com.cloudsigns.factorymanager2.project.myinerface.ItemClickListener;

import java.util.ArrayList;
import java.util.List;

/**
 * 查看施工内容
 * Created by tony on 2018/2/2.
 */

public class ViewConstructContentAdapter extends BaseAdapter {
    private Context context;
    private List<EngineeringConstructContentBean> datas = new ArrayList<EngineeringConstructContentBean>();
    private LayoutInflater inflater;
    private String tag = "";
    private ItemClickListener itemClickListener;
    private ItemCheckedChangeListener itemCheckedChangeListener;


    public ViewConstructContentAdapter(Context context, String tag) {
        this.context = context;
        this.inflater = LayoutInflater.from(context);
        this.tag = tag;
    }

    public void setItemClickListener(ItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }

    public void setItemCheckedChangeListener(ItemCheckedChangeListener itemCheckedChangeListener) {
        this.itemCheckedChangeListener = itemCheckedChangeListener;
    }

    ;

    public void setData(List<EngineeringConstructContentBean> list) {
        this.datas.clear();
        if (null != list) {
            this.datas.addAll(list);
        }

    }


    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public EngineeringConstructContentBean getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup viewGroup) {
        final ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();

            convertView = inflater.inflate(R.layout.item_view_construct_conent_lv, null);
            holder.img_rb = convertView.findViewById(R.id.img_rb);
            holder.tv_content = convertView.findViewById(R.id.tv_content);
            holder.tv_name = convertView.findViewById(R.id.tv_name);


            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        EngineeringConstructContentBean bean = datas.get(position);
//        if (bean.getChecked()) {
//            holder.img_rb.setBackgroundResource(R.mipmap.icon_radio_bg_yes);
//        } else {
//            holder.img_rb.setBackgroundResource(R.mipmap.icon_radio_no);
//        }
//
//        holder.tv_content.setText(bean.getContent());


        return convertView;
    }

    private class ViewHolder {
        private ImageView img_rb;
        private TextView tv_content;
        private TextView tv_name;

    }

}
